<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Tournaments extends CI_Model {

    
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
        
    function getAllTournament()
    {
        $query = $this->db->get_where('ss_tournament', array('enabled' => 1));
        
        return $query->result();
    }

    function get_tournament($tournamentid){
    	
    	$query = $this->db->get_where('ss_tournament', array('tournamentid' => $tournamentid));
    	
    	return $query->result();
    	
    }

    function create_tournament($name,$start_date,$end_date,$enabled)
    {
    	$this->tour_name = $name; // please read the below note
    	$this->start_date = $start_date;
    	$this->end_date = $end_date;
    	$this->enabled = $enabled;
    	$this->create_date = date("Y-m-d H:i:s");
    
    	$this->db->insert('ss_tournament', $this);
    }
    
    function edit_tournament($tournamentid,$name,$start_date,$end_date,$enabled)
    {
    	$this->tour_name = $name; // please read the below note
    	$this->start_date = $start_date;
    	$this->end_date = $end_date;
    	$this->enabled = $enabled;
    	    
    	$this->db->update('ss_tournament', $this, array('tournamentid' => $tournamentid));
    }
    
    function delete_tournament($tournamentid){
    	$this->db->delete('ss_tournament', array('tournamentid' => $tournamentid));
    }
    
  
}